import request from '#/utils/requestAbort';

export async function fetchTradeTime() {
  // 获取当前交易中心的当前时间
  return request(`/predictive/tradeTime/fetchTradeTime`);
}

export async function fetchDetail(params) {
  // 获取策略详情
  return request(`/predictive/rollingBatchStrategy/fetchDetail`, {
    params: params,
  });
}

export async function fetchTradePriceLimit(params) {
  // 获取交易限价信息
  return request(`/predictive/tradePriceLimit/fetchData`, {
    params: params,
  });
}

export async function fetchProvinces() {
  // 获取省份选择列表，暂时只能获取到山西的信息
  return request(`/predictive/rollingBatchStrategy/fetchProvinces`);
}

export async function postQueryProvinceList(menuCode) {
  // 获取省份选择列表
  return request(`/power/dataPower/common/${menuCode}/t_station`, {
    method: 'GET',
  });
}

export async function fetchSequences(date) {
  // 获取交易序列（复用滚动批量申报接口）
  return request(`/predictive/rollingBatch/fetchSequences/${date}`);
}

export async function fetchForceForecastDatasourceList(params) {
  // 获取出力预测数据源列表
  return request(`/predictive/rollingBatchStrategy/fetchForceForecastDatasourceList`, {
    params: params,
  });
}

export async function fetchForceForecastChartData(params) {
  // 获取出力预测数据源图表数据
  return request(`/predictive/rollingBatchStrategy/fetchForceForecastChartData`, {
    params: params,
  });
}

export async function globalForceDatasourceConfig(data) {
  // 设置出力预测数据源
  return request(`/predictive/rollingBatchStrategy/globalForceDatasourceConfig`, {
    method: 'POST',
    data: data,
  });
}

export async function fetchPriceForecastDatasourceList(params) {
  // 获取现货价格预测数据源列表
  return request(`/predictive/rollingBatchStrategy/fetchPriceForecastDatasourceList`, {
    params: params,
  });
}

export async function fetchPriceForecastChartData(params) {
  // 获取电价预测数据源图表数据
  return request(`/predictive/rollingBatchStrategy/fetchPriceForecastChartData`, {
    params: params,
  });
}

export async function globalPriceDatasourceConfig(data) {
  // 设置现货价格预测数据源
  return request(`/predictive/rollingBatchStrategy/globalPriceDatasourceConfig`, {
    method: 'POST',
    data: data,
  });
}

export async function save(data) {
  // 保存策略
  return request(`/predictive/rollingBatchStrategy/save`, {
    method: 'POST',
    data: data,
  });
}

export async function computedBenefits(data) {
  // 计算时点收益变动
  return request(`/predictive/rollingBatchStrategy/computedBenefits`, {
    method: 'POST',
    data: data,
  });
}

export async function computedPrice(data) {
  // 计算时点交易价格
  return request(`/predictive/rollingBatchStrategy/computedPrice`, {
    method: 'POST',
    data: data,
  });
}

export async function computedPower(data) {
  // 计算策略时点交易量
  return request(`/predictive/rollingBatchStrategy/computedPower`, {
    method: 'POST',
    data: data,
  });
}

export async function fetch3DChartData(params) {
  // 获取三维模型的图表数据
  return request(`/predictive/rollingBatchStrategy/fetch3DChartData`, {
    params: params,
  });
}

export async function fetchBenefitsComputedChartData(params) {
  // 获取计算收益截面图表数据
  return request(`/predictive/rollingBatchStrategy/fetchBenefitsComputedChartData`, {
    params: params,
  });
}

export async function fetchPriceComputedChartData(params) {
  // 获取计算交易价格截面图表数据
  return request(`/predictive/rollingBatchStrategy/fetchPriceComputedChartData`, {
    params: params,
  });
}

export async function fetchPowerComputedChartData(params) {
  // 获取计算交易量截面图表数据
  return request(`/predictive/rollingBatchStrategy/fetchPowerComputedChartData`, {
    params: params,
  });
}

export async function reConfigDatasource(data) {
  // 根据全局配置重新设置当前策略的数据源
  return request(`/predictive/rollingBatchStrategy/reConfigDatasource`, {
    method: 'POST',
    data: data,
  });
}

export async function listShortTermTradTactics(data) {
  // 获取新疆短期交易决策数据
  return request(`/predictive/xinjiangShortTermTradTactics/listShortTermTradTactics`, {
    method: 'POST',
    data: data,
  });
}

export async function saveShortTermTradTactics(data) {
  // 保存用户修改的交易策略数据
  return request(`/predictive/xinjiangShortTermTradTactics/saveShortTermTradTactics`, {
    method: 'POST',
    data: data,
  });
}

export async function exportXJData(data) {
  // 导出新疆短期交易决策数据
  return request(`/predictive/xinjiangShortTermTradTactics/export`, {
    method: 'POST',
    responseType: 'blob',
    data: data,
  });
}

export function getNxTradeSequence(data) {
  // 宁夏交易序列
  return request(`/predictive/ningXiaShortTermTradTactics/getTradeSequence`, {
    method: 'POST',
    data: data,
  });
}

export function getNxList(data) {
  // 宁夏列表
  return request(`/predictive/ningXiaShortTermTradTactics/listningXiaShortTermTradTactics`, {
    method: 'POST',
    data: data,
  });
}

export function saveNxList(data) {
  // 保存宁夏列表
  return request(`/predictive/ningXiaShortTermTradTactics/saveShortTermTradTactics`, {
    method: 'POST',
    data: data,
  });
}

export const nxImportUrl = '/predictive/ningXiaShortTermTradTactics/importForecastData';

export const nxDownloadTemplateUrl = '/predictive/ningXiaShortTermTradTactics/templateDownLoad';

export function exportNxData(data) {
  // 导出宁夏短期交易决策数据
  return request('/predictive/ningXiaShortTermTradTactics/export', {
    method: 'POST',
    responseType: 'blob',
    data: data,
  });
}

/**
 * 山西短期交易策略-新需求开发接口
 *
 *
 */
export function getTradeSequence(data) {
  // 山西短期交易序列获取
  return request(`/predictive/shanxiShortTermTrad/getTradeSequence`, {
    method: 'POST',
    data: data,
  });
}
export function shanxiShortTermTradDecision(data) {
  // 山西短期交易决策模型获取
  return request(`/predictive/shanxiShortTermTrad/shanxiShortTermTradDecision`, {
    method: 'POST',
    data: data,
  });
}
export function getHuiNenForecastVersion(data) {
  // 预测出力版本号获取
  return request(`/predictive/shanxiShortTermTrad/getHuiNenForecastVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getHuiNenForecastData(data) {
  // 预测出力数据获取
  return request(`/predictive/shanxiShortTermTrad/getHuiNenForecastData`, {
    method: 'POST',
    data: data,
  });
}
export function getTjForecastPriceVersion(data) {
  // 预测电价版本号获取
  return request(`/predictive/shanxiShortTermTrad/getTjForecastPriceVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getTjForecastPriceByVersion(data) {
  // 电价预测数据获取
  return request(`/predictive/shanxiShortTermTrad/getTjForecastPriceByVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getDealResultVersion(data) {
  // 交易结果版本号获取
  return request(`/predictive/shanxiShortTermTrad/getDealResultVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getDealPriceInfo(data) {
  // 交易结果数据获取
  return request(`/predictive/shanxiShortTermTrad/getDealPriceInfo`, {
    method: 'POST',
    data: data,
  });
}

export function saveForecastVersion(data) {
  // 保存预测版本
  return request(`/predictive/shanxiShortTermTrad/saveForecastVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getTransactionPowerVersion(data) {
  // 日滚历史成交电量版本号获取
  return request(`/predictive/shanxiShortTermTrad/getTransactionPowerVersion`, {
    method: 'POST',
    data: data,
  });
}
export function getTransactionPowerByVersion(data) {
  // 日滚历史成交电量数据获取
  return request(`/predictive/shanxiShortTermTrad/getTransactionPowerByVersion`, {
    method: 'POST',
    data: data,
  });
}

export function decisionSave(data) {
  // 山西短期交易决策模型保存
  return request(`/predictive/shanxiShortTermTrad/decisionSave`, {
    method: 'POST',
    data: data,
  });
}
export function decisionExport(data) {
  // 山西短期交易决策模型保存
  return request(`/predictive/shanxiShortTermTrad/decisionExport`, {
    method: 'POST',
    responseType: 'blob',
    data: data,
  });
}
